#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 2e5+10;

ll ans;
int n,k,h[N],f[N],cnt;

struct edge{int v,nxt;}e[N<<1];
void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

void dfs(int x,int p = 0){
	for(int i = h[x],y;i;i = e[i].nxt){
		if((y = e[i].v) == p) continue;
		dfs(y,x); f[x] += f[y];
		ans += min(f[y],k-f[y]);
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,k = in << 1;
	for(int i = 1;i <= k;i++) f[in]++;
	for(int i = 1;i < n;i++){
		int u = in,v = in;
		link(u,v); link(v,u);
	}
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}

